package trabajoISW2.tests;

import java.util.Calendar;

import org.junit.Before;
import org.junit.Test;

import trabajoISW2.domain.contracts.IOrder;
import trabajoISW2.domain.exceptions.WrongIdException;
import trabajoISW2.domain.implementations.Cart;
import trabajoISW2.domain.implementations.CreditCard;


public class OrderTestSuite {

	IOrder io;
	Calendar c;
	CreditCard ic;
	Cart cart;
	SuperTest st;
	
	@Before
	public void setup(){
		st = new SuperTest();
		st.inicializa();
		io = st.order1;
		c = Calendar.getInstance();
		ic = st.creditCard1;
		cart = st.cart1;
	}
	
	//Pruebas sobre el método getOrderId
	
	@Test
	public void testSetOrderId1(){
		io.setOrderId(0);
		io.setOrderId(Integer.MAX_VALUE);
		io.setOrderId(Integer.MAX_VALUE - 1);
		io.setOrderId(1);
	}
	
	@Test(expected = WrongIdException.class)
	public void testSetOrderId2(){
		io.setOrderId(-1);
		
	}
	
	@Test(expected = WrongIdException.class)
	public void testSetOrderId3(){
		io.setOrderId(Integer.MIN_VALUE);
	}
	
	@Test(expected = WrongIdException.class)
	public void testSetOrderId4(){
		io.setOrderId(Integer.MIN_VALUE + 1);
	}
	
	//Pruebas sobre el método setDate
	
	/*
	@Test
	public void testSetDate1(){
		
		io.setDate(c);
		c.set(2009, 1,20);
		io.setDate(c);
	}
	
	@Test (expected = IllegalArgumentException.class)
	public void testSetDate2(){
		 io.setDate(null);
	}
	
		
	@Test (expected = IllegalArgumentException.class)
	public void testSetDate3(){
		
		c.set(2012, 10, 25);
		io.setDate(c);
	}
	*/
	//Pruebas sobre el método setCreditCard
	
	@Test 
	public void testSetCreditCard(){
		io.setCreditCard(ic);
	}
	
	@Test (expected = IllegalArgumentException.class)
	public void testSetCreditCard2(){
		io.setCreditCard(null);
	}
	
	//Prubas sobre el método setInvoiceId
	
	/*@Test
	public void testSetInvoice(){
		io.setInvoice(in);
	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetInvoiceId2(){
		io.setInvoice(null);
		
	}*/
		
	//Pruebas sobre setCartId
	
	@Test
	public void testSetCart(){
		io.setCart(cart);

	}
	
	@Test(expected = IllegalArgumentException.class)
	public void testSetCartId2(){
		io.setCart(null);
		
	}
	
	
	
	
}
